package org.shop.pro.config.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.shop.pro.entity.Vip;
import org.shop.pro.service.VipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class VipController {
	@Autowired
	VipService vipService;
	
	@RequestMapping("/vip_list")
	public String viplist(Model model,HttpSession session) {
		List<Vip> vip= vipService.selectAll();
		model.addAttribute("viplist",vip);
		return "vip_list";
	}
	
	@RequestMapping("/vip_info")
	public String vipinfo(Integer id,Model model,HttpSession session) {
		if(id!=null){
			Vip vip = vipService.selectByPrimaryKey(id);
			model.addAttribute(vip);
			return "vip_info";
		}
		return "redirect:vip_list"; 
	}
	
	@RequestMapping("/vip_add")
	public String vipadd(Model model,HttpSession session) {
		return "vip_add"; 
	}

}
